<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<?php      

     $dtpApplyDate=(isset($ApplyDate) && !empty($ApplyDate) && is_date($ApplyDate)) ? $ApplyDate : date('Y-m-d');     
     $dtpApplyDate=str_replace('/','-',$dtpApplyDate); 
     $arrApplyDate= explode('-', $dtpApplyDate) ;   

?>
<script>

        $(function() {
            var defaultYear= <?php echo $arrApplyDate[0] ?>;
            var defaultMonth= <?php echo $arrApplyDate[1]-1 ?>; 
            $( "#datepicker" ).datepicker({
              showOn: "button",
              buttonImage: "/public/sites/images/calendaricon.gif",
              dateFormat: 'yy/mm',
              yearRange: '<?php echo $this->session->userdata('minYear') . ':' . $this->session->userdata('maxYear'); ?>',
              changeMonth: true,
              changeYear: true,
              buttonImageOnly: true,
              showButtonPanel:true,
              //defaultDate: '<?php echo $dtpApplyDate; ?>',
              
              
              beforeShowDay: function(date) {
                    return [date.getDate() == 1]
                },
              onClose: function(dateText, inst) { 
                var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
                var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
                $(this).datepicker('setDate', new Date(year, month, 1));
                }  ,
                        defaultDate: new Date(defaultYear,defaultMonth,1)
            });
          });
 
</script>
<style>
    .ui-datepicker-calendar {
    display: none;
    }​    
    button.ui-datepicker-current{ display: none !important;}
/*   .ui-datepicker table{
       display: none;
   }*/
</style>
<div id="main_content" class="other">
	<h3><?php echo $this->lang->line('spr__Title_Update'); ?></h3>
    <div class="form_add">
	<?php  
       echo "<label for='disabledSelect' style='color:red;'>".$this->session->flashdata('message')."</label>";
    ?>    
    <form action="" method="post">
       <table border="0" class="add_data">
                <tr>
                    <td><a href="<?php echo base_url(); ?>salary-parameter" class="btn addEmoloyeeBack m10"><?php echo $this->lang->line('MC013'); ?></a></td>  
                </tr>
       		<tr>
            	<td align="right">
                	<label><?php echo $this->lang->line('spr__Applydate'); ?> <span class="requied"> (*)</span></label>
                </td>
                <td>
                        <p><?php                     
                            function is_date( $str ){                               
                                if(strlen($str)==7 || strlen($str)==10){
                                    $stamp = strtotime( $str ); 
                                    if (!is_numeric($stamp)) 
                                        return FALSE; 
                                    $month = date( 'm', $stamp );
                                    //$day   = date( 'd', $stamp ); 
                                    $year  = date( 'Y', $stamp ); 
                                    $day=1;                                    
                                    if (checkdate($month, $day, $year)) 
                                        return TRUE; 
                                }else{
                                    return FALSE; 
                                }
                            }
                            if(isset($ApplyDate) && !empty($ApplyDate) && is_date($ApplyDate)){
                                 $ApplyDate=date("Y/m", strtotime($ApplyDate));
                            }elseif(isset($ApplyDate) && !empty($ApplyDate)){
                                $ApplyDate=$ApplyDate;
                            }else{
                                $ApplyDate="";
                            }
                            $options = array(
                                    'name'        => 'txtApplyDate',
                                    'id'          => 'datepicker',
                                    'value'       => $ApplyDate,
                                     'maxlength'   =>7,
                                    'size'        => '20',                                   
                                  );
                        ?>
                             <?php echo form_input($options)  ; ?>            	
                            <?php echo $this->lang->line('emp_bu_formatDate');?>
                            </td>
                <td>
                    <span class="error"><?php echo form_error('txtApplyDate'); ?><?php echo isset($errDuplicateDate) ?  $errDuplicateDate: ''; ?></span>
                </td>
            </tr>       
       		<tr>
            	<td align="right">
                	<label><?php echo $this->lang->line('spr__Trialperiodrate'); ?> <span class="requied"> (*)</span></label>
                </td>
                <td>       
                        <?php 
                            $optionTrialPeriodRate = array(
                                    'name'        => 'txtTrialPeriodRate',                                   
                                    'value'       => isset($TrialPeriodRate) ? $TrialPeriodRate : '',
                                    'maxlength'   => '5'                                   
                                  );
                           ?> 
                        <?php echo form_input($optionTrialPeriodRate )  ; ?>
                        
                </td>
                <td>
                    <span class="error"><?php echo form_error('txtTrialPeriodRate'); ?></span>
                </td>
            </tr>
       		<tr>
            	<td align="right">
                	<label><?php echo $this->lang->line('spr__Weekdayovertimerate'); ?> <span class="requied"> (*)</span></label>
                </td>
                <td>
                    <?php 
                            $optionWeekdayOvertimeRate = array(
                                    'name'        => 'txtWeekdayOvertimeRate',                                   
                                    'value'       => isset($WeekdayOvertimeRate) ? $WeekdayOvertimeRate : '',
                                    'maxlength'   => '5'                                   
                                  );
                           ?>
                     <?php echo form_input($optionWeekdayOvertimeRate)  ; ?>                	
                    
                </td>
                <td>
                        <span class="error"><?php echo form_error('txtWeekdayOvertimeRate'); ?>
                </td>
            </tr>
       		<tr>
            	<td align="right">
                	<label><?php echo $this->lang->line('spr__Weekdaylateovertimerate'); ?> <span class="requied"> (*)</span></label>
                </td>
                <td>
                    <?php 
                            $optionWeekdayLateOvertimeRate = array(
                                    'name'        => 'txtWeekdayLateOvertimeRate',                                   
                                    'value'       => isset($WeekdayLateOvertimeRate) ? $WeekdayLateOvertimeRate : '',
                                    'maxlength'   => '5'                                   
                                  );
                           ?>
                	<?php echo form_input($optionWeekdayLateOvertimeRate)  ; ?>
                        
                </td>
                <td>
                    <span class="error"><?php echo form_error('txtWeekdayLateOvertimeRate'); ?>
                </td>
            </tr>
       		<tr>
            	<td align="right">
                	<label><?php echo $this->lang->line('spr__Weekendovertimerate'); ?> <span class="requied"> (*)</span></label>
                </td>
                <td>
                    <?php 
                            $optionWeekendOvertimeRate = array(
                                    'name'        => 'txtWeekendOvertimeRate',                                   
                                    'value'       => isset($WeekendOvertimeRate) ? $WeekendOvertimeRate : '',
                                    'maxlength'   => '5'                                   
                                  );
                           ?>
                	<?php echo form_input($optionWeekendOvertimeRate )  ; ?>
                        
                </td>
                <td>
                    <span class="error"><?php echo form_error('txtWeekendOvertimeRate'); ?>
                </td>
            </tr>
       		<tr>
            	<td align="right">
                	<label><?php echo $this->lang->line('spr__Weekendlateovertimerate'); ?><span class="requied"> (*)</span> </label>
                </td>
                <td>
                    <?php 
                            $optionWeekendLateOvertimeRate = array(
                                    'name'        => 'txtWeekendLateOvertimeRate',                                   
                                    'value'       => isset($WeekendLateOvertimeRate) ? $WeekendLateOvertimeRate : '',
                                    'maxlength'   => '5'                                   
                                  );
                           ?>
                	<?php echo form_input($optionWeekendLateOvertimeRate)  ; ?>
                        
                </td>
                <td>
                    <span class="error"><?php echo form_error('txtWeekendLateOvertimeRate'); ?>
                </td>
            </tr>
       		<tr>
            	<td align="right">
                	<label><?php echo $this->lang->line('spr__Holidayovertimerate'); ?> <span class="requied"> (*)</span></label>
                </td>
                <td>
                         <?php 
                            $optionHolidayOvertimeRate = array(
                                    'name'        => 'txtHolidayOvertimeRate',                                   
                                    'value'       => isset($HolidayOvertimeRate) ? $HolidayOvertimeRate : '',
                                    'maxlength'   => '5'                                   
                                  );
                           ?>
                	<?php echo form_input($optionHolidayOvertimeRate)  ; ?>
                        
                </td>
                <td>
                    <span class="error"><?php echo form_error('txtHolidayOvertimeRate'); ?>
                </td>
            </tr>
       		<tr>
            	<td align="right">
                	<label><?php echo$this->lang->line('spr__Holidayovertimerate'); ?><span class="requied"> (*)</span> </label>
                </td>
                <td>
                        <?php 
                            $optionHolidayLateOvertimeRate = array(
                                    'name'        => 'txtHolidayLateOvertimeRate',                                   
                                    'value'       => isset($HolidayLateOvertimeRate) ? $HolidayLateOvertimeRate : '',
                                    'maxlength'   => '5'                                   
                                  );
                           ?>
                	<?php echo form_input($optionHolidayLateOvertimeRate)  ; ?>
                        
                </td>
                <td>
                    <span class="error"><?php echo form_error('txtHolidayLateOvertimeRate'); ?>
                </td>    
            </tr>
       		<tr>
            	<td align="right">
                	<label><?php echo $this->lang->line('spr__Socialinsurancerate'); ?><span class="requied"> (*)</span></label>
                </td>
                <td>
                        <?php 
                            $optionSocialInsuranceRate = array(
                                    'name'        => 'txtSocialInsuranceRate',                                   
                                    'value'       => isset($SocialInsuranceRate) ? $SocialInsuranceRate : '',
                                    'maxlength'   => '5'                                   
                                  );
                           ?>
                	<?php echo form_input($optionSocialInsuranceRate)  ; ?>
                        
                </td>
                <td>
                    <span class="error"><?php echo form_error('txtSocialInsuranceRate'); ?>
                </td>
            </tr>            
       		<tr>
            	<td align="right">
                	<label><?php echo $this->lang->line('spr__Medicalinsurancerate'); ?><span class="requied"> (*)</span></label>
                </td>
                <td>
                        <?php 
                            $optionMedicalInsuranceRate = array(
                                    'name'        => 'txtMedicalInsuranceRate',                                   
                                    'value'       => isset($MedicalInsuranceRate) ? $MedicalInsuranceRate : '',
                                    'maxlength'   => '5'                                   
                                  );
                           ?>
                	<?php echo form_input($optionMedicalInsuranceRate)  ; ?>
                        
                </td>
                <td>
                    <span class="error"><?php echo form_error('txtMedicalInsuranceRate'); ?>
                </td>
            </tr>
       		<tr>
       		<tr>
            	<td align="right">
                	<label><?php echo $this->lang->line('spr__Unemploymentinsurancerate'); ?><span class="requied"> (*)</span></label>
                </td>
                <td>
                        <?php 
                            $optionUnemploymentInsuranceRate = array(
                                    'name'        => 'txtUnemploymentInsuranceRate',                                   
                                    'value'       => isset($UnemploymentInsuranceRate) ? $UnemploymentInsuranceRate : '',
                                    'maxlength'   => '5'                                   
                                  );
                           ?>
                	<?php echo form_input($optionUnemploymentInsuranceRate)  ; ?>
                        
                </td>
                <td>
                    <span class="error"><?php echo form_error('txtUnemploymentInsuranceRate'); ?>
                </td>
            </tr>
            <?php if(isset($Del_Flag)){ ?>
            <tr>
                <td align="right"><?php echo $this->lang->line('spl__Delete');?></td>
                <td><input type="checkbox" <?php echo ($Del_Flag==1) ? 'checked' : ''?> name="chkDelete" /></td>
            </tr>
            <?php } ?>
       		<tr>         
                <td colspan="2" align="left">
                    <input type="hidden" id="hidSalaryParameterID" name="hidSalaryParameterID" value="<?php echo $Id ?>">
                	<input type="hidden" value="true" name="btnButton"/>
                        <input id="btnSubmit" name="btnSubmit" type="submit" value="<?php echo $this->lang->line('MC008'); ?>">
                    <input style="display:none;" type="reset" name="reset" value="<?php echo $this->lang->line('MC009'); ?>">
                </td>
            </tr>                                                                                         
       </table> 
    </form>
        
    </div>
</div>
<div  id="dialog" title="<?php echo $dialogTitle; ?>">
    <?php echo isset($message) ? $message : ''; ?>
</div>
<script type="text/javascript">
     
<?php if (isset($flag) && $flag == TRUE): ?>
            $(function() {
                $("#dialog").dialog({
                    closeText: "hide",
                    modal: true,
                    close: function() {
                        window.location.href = '<?php echo base_url('/salary-parameter'); ?>';
                    },
                     buttons: [{
                            text: '<?php echo $this->lang->line('MC019'); ?>',
                            click: function() {
                                window.location.href = '<?php echo base_url('/salary-parameter'); ?>';
                            }
                        }],
                });
            });
<?php elseif (isset($flag) && $flag == FALSE): ?>
            $(function() {
                $("#dialog").dialog({
                    resizable: false,
                    height:140,
                    modal: true,
                    buttons: [{
                            text: '<?php echo $this->lang->line('MC019'); ?>',
                            click: function() {
                                $("#dialog").dialog('close');
                            }
                        }]
                  });
            });
<?php endif; ?>
   
</script>